﻿using System;

namespace MulticastDelegates
{
    class Program
    {


        static void Main()
        {
            Console.WriteLine("系统委托");
            Func<double,string> func1 = new Func<double, string>(MathOperations.MultiplyByTwo);
            func1 += MathOperations.Square;
            ProcessAndDisplayNumber(func1, 2.0);
            ProcessAndDisplayNumber(func1, 7.94);
            Console.WriteLine();

            //Action<double> operations = MathOperations.MultiplyByTwo;
            //operations += MathOperations.Square;
            //ProcessAndDisplayNumber(operations, 2.0);
            //ProcessAndDisplayNumber(operations, 7.94);
            //Console.WriteLine();
        }


        static void ProcessAndDisplayNumber(Func<double, string> action, double value)
        {
            Console.WriteLine();
            Console.WriteLine(action(value)); 
        }

        //static void ProcessAndDisplayNumber(Action<double> action, double value)
        //{
        //    Console.WriteLine();
        //    Console.WriteLine($"输出值为 = {value}");
        //    action(value);
        //}

        //static void ProcessAndDisplayNumber(Action<double> action, double value)
        //{
        //    Console.WriteLine();
        //    Console.WriteLine($"ProcessAndDisplayNumber called with value = {value}");
        //    action(value);
        //}
    }
}
